package com.service.impl;

import com.mapper.StartstopMapper;
import com.pojo.Startstop;
import com.service.StartStopService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Service("startStopService")
public class StartStopServiceImpl implements StartStopService {
    @Resource
    private StartstopMapper startstopMapper;
    @Override
    public List<Startstop> selectStartStopByOwnerId(Integer ownerid) {
        List<Startstop> startstops = startstopMapper.selectStartStopByOwnerId(ownerid);
        return startstops;
    }

    @Override
    public int addStartStop(Startstop startstop) {
        Date date = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        startstop.setStarttime(formatter.format(date));
        int i = startstopMapper.addStartStop(startstop);
        return i;
    }

    @Override
    public int deleteStartStopById(Integer id) {
        int i = startstopMapper.deleteStartStopById(id);
        return i;
    }

    @Override
    public Startstop selectStartStopByParkLotId(Integer parklotid) {
        Startstop startstop = startstopMapper.selectStartStopByParkLotId(parklotid);
        return startstop;
    }
}
